/*
 * (c) LOIS, Ltd., 2004
 * 
 * $Id: MySqlConnector.java,v 1.1 2011/01/29 11:01:52 dell Exp $
 */
package ru.jexp.tl.db.mysql;

import java.sql.Connection;
import java.util.Properties;

import oracle.toplink.sessions.DefaultConnector;
import oracle.toplink.sessions.Session;
import ru.jexp.tl.db.WrapConnector;

public class MySqlConnector extends WrapConnector
{
    private String characterEncoding;
    
    public MySqlConnector(DefaultConnector connector)
    {
        super(connector);
        this.characterEncoding = null;
    }
    
    public MySqlConnector(DefaultConnector connector, String characterEncoding)
    {
        super(connector);
        this.characterEncoding = characterEncoding;
    }
    
    public Connection connect(Properties properties,Session session)
    {
        properties.put("useUnicode", "true");
        properties.put("characterEncoding", (characterEncoding == null ? "Cp1251" : characterEncoding));
        properties.put("autoReconnect", "true");
        Connection connect = super.connect(properties,session);
                return connect;
    }
}
